//
//  UIImage+ext.m
//  WanLian
//
//  Created by 123456 on 2019/1/24.
//  Copyright © 2019 wanlian. All rights reserved.
//

#import "UIImage+ext.h"

@implementation UIImage (ext)

+ (void)compressImageWithURL:(NSURL *)url rate:(float)rate completeBlock:(void (^)(UIImage *image))complete {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        UIImage *image = [UIImage imageWithContentsOfFile:url.path];
        NSData *data = UIImageJPEGRepresentation(image, rate);
        UIImage *resImage = [UIImage imageWithData:data];;
        dispatch_async(dispatch_get_main_queue(), ^{
            if (complete) {
                complete(resImage);
            }
        });
    });
}
@end
